package com.gaoyi.crm.util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;

public class WindowUtil {

    public static void setWindowDecorView(Activity activity) {
        Window window = activity.getWindow();
        View decorView = window.getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        decorView.setFitsSystemWindows(true);
        window.setStatusBarColor(Color.TRANSPARENT);
    }

    public static void setBarBgColor(Activity activity, int color) {
        activity.getWindow().setStatusBarColor(activity.getResources().getColor(color));
    }

    public static void hideSoftInput(View view) {
        InputMethodManager imm = (InputMethodManager) AppUtil.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }
}
